
import request from "@/utils/request.js";



/**
 * 获取店铺列表
 *
 */
export function getStoreList(data) {
	return request.get('user/services', data);
}


/**
 * 统计数据
 */
export function getStatisticsInfo() {
  return request.get("shop/order/statistics", {}, { login: true });
}
/**
 * 订单月统计
 */
export function getStatisticsMonth(where) {
  return request.get("shop/order/data", where, { login: true });
}
/**
 * 订单月统计
 */
export function getAdminOrderList(where) {
  return request.get("shop/order/list", where, { login: true });
}
/**
 * 订单改价
 */
export function setAdminOrderPrice(merId,id,data) {
  return request.post("shop/price/"+id, data, { login: true });
}
/**
 * 订单备注
 */
export function setAdminOrderRemarkJoin(merId,id,data) {
  return request.post("admin/order/mark/" +id, data, { login: true });
}

/**
 * 订单备注
 */
export function setAdminOrderRemark(merId,id,data) {
  return request.post("shop/mark/" +id, data, { login: true });
}

/**
 * 订单详情
 */
export function getAdminOrderDetail(merId, orderId) {
  return request.get("shop/order/" + orderId, {}, { login: true });
}

/**
 * 订单详情
 */
export function getAdminOrderDetailJoin(merId, orderId) {
  return request.get("admin/order/get?orderId=" + orderId, {}, { login: true });
}

/**
 * 订单发货信息获取
 */
export function getAdminOrderDelivery(orderId) {
  return request.get( "shop/order/delivery/gain/" + orderId,{},{ login: true });
}

/**
 * 订单发货保存
 */
export function setAdminOrderDelivery(merId,id,data) {
  return request.post("shop/delivery/"+ id, data, { login: true });
}

/**
 * 订单发货保存
 */
export function setAdminOrderDeliveryJoin(merId,data) {
  return request.post("admin/order/delivery", data, { login: true });
}

/**
 * 订单统计图
 */
export function getStatisticsTime(data) {
  return request.get("shop/order/time", data, { login: true });
}
/**
 * 线下付款订单确认付款
 */
export function setOfflinePay(merId, data) {
  return request.post("shop/order/offline", data, { login: true });
}
/**
 * 订单确认退款
 */
export function setOrderRefund(merId,data) {
  return request.post("shop/order/refund", data, { login: true });
}

/**
 * 获取快递公司
 * @returns {*}
 */
export function getLogistics() {
  return request.get("logistics", {}, { login: false });
}

/**
 * 订单核销
 * @returns {*}
 */
export function orderVerific(data) {
  // return request.post("verifier/"+code);
	return request.post(`verifier/${data.mer_id}/${data.id}`);
}

/**
 * 核销订单详情
 * @returns {*}
 */
export function verifierOrder(mer_id,code) {
  return request.get("verifier/"+mer_id+"/order/"+code);
}

/**
 * 订单统计数
 * @returns {*}
 */
export function orderStatistics(mer_id) {
  return request.get("shop/statistics");
}

/**
 * 订单统计数
 * @returns {*}
 */
export function orderStatisticsJoin(mer_id) {
  return request.post("shop/report/statistics",{}, { login: true });
}

/**
 * 每日成交额
 * @returns {*}
 */
export function orderPrice(where, mer_id) {
  return request.get("shop/orderPrice", where, { login: true });
}

/**
 * 每日成交额
 * @returns {*}
 */
export function orderPriceJoin(where, mer_id) {
  return request.get("shop/report/getDayList", where, { login: true });
}


/**
 * 订单列表
 * @returns {*}
 */
export function getOrderList(where, merId) {
  return request.get(`admin/order_list`, where, { login: true });
}

/**
 * 订单列表
 * @returns {*}
 */
export function getOrderList2(where, merId) {
  return request.get(`admin/order/list`, where, { login: true });
}

/**
 * 发货
 * @returns {*}
 */
export function order(where, merId) {
  return request.get(`admin/order/list`, where, { login: true });
}


/**
 * 退款订单列表
 * @returns {*}
 */
export function getRefundOrderList(where, merId) {
  return request.get(`server/refund/lst`, where, { login: true });
}
/**
 * 营业额统计
 * @returns {*}
 */
export function turnoverStatistics(where, merId) {
  return request.get(`admin/${merId}/pay_price`, where, { login: true });
}
/**
 * 订单统计
 * @returns {*}
 */
export function orderNumberStatistics(where, merId) {
  return request.get(`admin/${merId}/pay_number`, where, { login: true });
}
/**
 * 获取订单打印默认配置
 * @returns {*}
 */
export function orderDeliveryInfo(merId) {
  return request.get(`admin/${merId}/mer_form`);
}
/**
 * 获取电子面单列表
 * @returns {*}
 */
export function orderExportTemp(data) {
  return request.get("store/expr/temps", data);
}
/**
 * 是否开始电子面单和同城配送
 * @returns {*}
 */
export function getTempAndDelivery(merId) {
  return request.get(`admin/${merId}/delivery_config`);
}
/**
 * 获取同城配送门店列表
 * @returns {*}
 */
export function getDeliveryStoreLst(merId) {
  return request.get(`admin/${merId}/delivery_options`);
}
/**
 * 退款订单信息
 * @returns {*}
 */
export function getRefundOrderInfo(merId,id) {
  return request.get(`server/${merId}/refund/get/${id}`);
}
/**
 * 提交退款订单信息
 * @returns {*}
 */
export function refundOrderSubmit(merId,id,data) {
  return request.post(`server/${merId}/refund/status/${id}`,data, { login: true });
}
/**
 * 退款单确认收货
 * @returns {*}
 */
export function refundOrderReceive(merId,id) {
  return request.post(`server/${merId}/refund/confirm/${id}`,{}, { login: true });
}
/**
 * 退款单详情
 */
export function getRefundOrderDetail(merId, orderId) {
  return request.get(`server/${merId}/refund/detail/${orderId}`,{}, { login: true });
}
/**
 * 添加退款单备注信息
 */
export function setRefundMark(merId, orderId, data) {
  return request.post(`server/${merId}/refund/mark/${orderId}`,data, { login: true });
}


/**
 * 添加订单备注信息
 */
export function setRemark(orderId, data) {
	
    let formData =Object.assign({}, data)
	console.log("formData",)
	
  return request.post(`admin/order/mark`,data, { login: true });
}


/**
 * 订单核销
 */
export function writeOff(orderId, data) {
	  let formData =Object.assign({}, data)
  return request.post(`admin/order/writeOff`,formData, { login: true });
}




/**
 * 获取产品详情
 * @param int id
 *
 */
export function getProductDetail(id) {
	return request.get('store/product/detail/' + id, {}, {
		noAuth: true
	});
}
/**
 * 获取预览商品详情
 * @param int id
 *
 */
export function getPreviewProDetail(data) {
	return request.get('store/product/preview', data, {
		noAuth: true
	});
}
/**
 * 产品分享二维码 推广员
 * @param int id
 */
export function getProductCode(id, data) {
	return request.get('store/product/qrcode/' + id, data);
}
/**
 * 添加收藏
 * @param int id
 * @param string category product=普通产品,product_seckill=秒杀产品
 */
export function collectAdd(data) {
	return request.post('user/relation/create', data);
}
/**
 * 删除收藏产品
 * @param int id
 * @param string category product=普通产品,product_seckill=秒杀产品
 */
export function collectDel(data) {
	return request.post('user/relation/delete', data);
}
/**
 * 购车添加
 *
 */
export function postCartAdd(data) {
	return request.post('user/cart/create', data);
}

/**
 * 获取分类列表
 *
 */
export function getCategoryList() {
	return request.get('store/product/category/lst', {}, {
		noAuth: true
	});
}
/**
 * 获取产品列表
 * @param object data
 */
export function getProductslist(data) {
	if (data.brand_id && Array.isArray(data.brand_id)) {
		data = {
			...data
		}
		data.brand_id = data.brand_id.toString()
	}
	return request.get('product/spu/lst', data, {
		noAuth: true
	});
}
/**
 * 获取优惠券商品列表
 * @param object data
 */
export function getCouponProductlist(data) {
	if (data.brand_id && Array.isArray(data.brand_id)) {
		data = {
			...data
		}
		data.brand_id = data.brand_id.toString()
	}
	return request.get('product/spu/coupon_product', data, {
		noAuth: true
	});
}
/**
 * 获取品牌列表
 * @param object data
 */
export function getBrandlist(data) {
	return request.get('store/product/brand/lst', data, {
		noAuth: true
	});
}
/**
 * 获取推荐产品
 *
 */
export function getProductHot(page, limit) {
	return request.get("product/spu/recommend", {
		page: page === undefined ? 1 : page,
		limit: limit === undefined ? 10 : limit
	}, {
		noAuth: true
	});
}
/**
 * 获取商户推荐产品
 *
 */
export function getMerProductHot(id,data) {
	return request.get(`product/spu/recommend`, {
		page: data.page === undefined ? 1 : data.page,
		limit: data.limit === undefined ? 10 : data.limit,
		mer_id: id || ''
	}, {
		noAuth: true
	});
}
/**
 * 批量收藏
 *
 * @param object id
 * @param string category
 */
export function collectAll(data) {
	return request.post('user/relation/batch/create', data);
}
/**
 * 首页产品的轮播图和产品信息
 * @param int type
 *
 */
export function getGroomList(type, data) {
	return request.get('product/spu/hot/' + type, data, {
		noAuth: true
	});
}
/**
 * 获取商品收藏列表
 * @param object data
 */
export function getCollectUserList(data) {
	return request.get('user/relation/product/lst', data)
}
/**
 * 获取商品收藏列表 -- 删除
 * @param object data
 */
export function userCollectDel(data) {
	return request.post('user/relation/lst/delete', data)
}
/**
 * 获取产品评论
 * @param int id
 * @param object data
 *
 */
export function getReplyList(id, data) {
	return request.get('store/product/reply/lst/' + id, data, {
		noAuth: true
	})
}
/**
 * 产品评价数量和好评度
 * @param int id
 */
export function getReplyConfig(id) {
	return request.get('reply/config/' + id);
}
/**
 * 获取搜索关键字获取
 *
 */
export function getSearchKeyword() {
	return request.get('common/hot_keyword', {}, {
		noAuth: true
	});
}
/**
 * 门店列表
 * @returns {*}
 */
export function storeListApi(data) {
	return request.get("store_list", data, {
		noAuth: true
	});
}
/**
 * 商户列表
 * @returns {*}
 */
export function storeMerchantList(data) {
	return request.get("store/merchant/lst", data, {
		noAuth: true
	});
}
/**
 * 获取商铺详情
 * @param {Object} id 商铺id
 * @param {Object} data 商铺数据
 */
export function getStoreDetail(id, data) {
	return request.get("store/merchant/detail/" + id, data, {
		noAuth: true
	});
}
/**
 * 获取商铺商品列表
 * @param {Object} id 商铺 id
 * @param {Object} data 商铺商品列表数据
 */
export function getStoreGoods(id, data) {
	return request.get("product/spu/merchant/" + id, data, {
		noAuth: true
	});
}
/**
 * 获取商铺分类列表
 * @param {Object} id 商铺 id
 * @param {Object} data
 */
export function getStoreCategory(id, data) {
	return request.get("store/merchant/category/lst/" + id, data, {
		noAuth: true
	});
}
/**
 * 关注商铺
 * @param {Object} type_id 商铺 id
 */
export function followStore(type_id) {
	return request.post("user/relation/create", {
		type: 10,
		type_id: type_id
	});
}
/**
 * 取消商铺关注
 * @param {Object} type_id 商铺 id
 */
export function unfollowStore(type_id) {
	return request.post("user/relation/delete", {
		type: 10,
		type_id: type_id
	});
}
/**
 * 获取商铺优惠券
 * @param {Object} id
 */
export function getStoreCoupon(id) {
	return request.get("coupon/store/" + id, {
		noAuth: true
	});
}
/**
 * 获取商铺优惠券
 */
export function getMerchantLst(data) {
	return request.get("user/relation/merchant/lst", data, {
		noAuth: true
	});
}
/**
 * 物流信息
 */
export function express(id) {
	return request.post("ordero/express/" + id, {
		noAuth: true
	});
}
/**
 * 子集分类
 * @returns {*}
 */
export function storeCategory(pid) {
	return request.get("store/product/category", pid, {
		noAuth: true
	});
}
/**
 * 分销说明
 * @returns {*}
 */
export function bagExplain() {
	return request.get("store/product/bag/explain");
}
/**
 * 分销礼包推荐列表
 * @returns {*}
 */
export function bagRecommend() {
	return request.get("product/spu/bag/recommend");
}
/**
 * 分销礼包列表
 * @returns {*}
 */
export function productBag(data) {

	return request.get("product/spu/bag", data, {
		noAuth: true
	});
}
/**
 * 商铺二维码
 * @returns {*}
 */
export function merchantQrcode(id, data) {
	return request.get("store/merchant/qrcode/" + id, data, {
		noAuth: true
	});
}
/**
 * 推荐商品
 * @returns {*}
 */
export function merchantProduct(id, data) {
	if (data.brand_id && Array.isArray(data.brand_id)) {
		data = {
			...data
		}
		data.brand_id = data.brand_id.toString()
	}
	return request.get("product/spu/merchant/" + id, data, {
		noAuth: true
	});
}
/**
 * 推荐商品banner
 * @returns {*}
 */
export function getHotBanner(type) {
	return request.get("common/hot_banner/" + type, {}, {
		noAuth: true
	});
}
/**
 * 商户入驻表单
 * @returns {*}
 */
export function create(data) {
	return request.post("intention/create", data);
}
/**
 * 商户入驻短信验证码
 * @returns {*}
 */
export function verify(data) {
	return request.post("auth/verify", data);
}
/**
 * 获取秒杀商品详情
 * @param int id
 *
 */
export function getSeckillProductDetail(id) {
	return request.get('store/product/seckill/detail/' + id, {}, {
		noAuth: true
	});
}
/**
 * 直播推荐列表
 * @returns {*}
 */
export function getLiveList(data) {
	return request.get(`broadcast/hot`, data, {
		noAuth: true
	});
}
/**
 * 直播列表
 * @returns {*}
 */
export function getBroadcastListApi(data) {
	return request.get("broadcast/lst", data, {
		noAuth: true
	});
}
/**
 * 商户分类
 * @returns {*}
 */
export function merClassifly() {
	return request.get("intention/cate", {}, {
		noAuth: true
	});
}
/**
 * 获取预售商品详情
 * @param int id
 *
 */
export function getPresellProductDetail(id) {
	return request.get('store/product/presell/detail/' + id, {}, {
		noAuth: true
	});
}
/**
 * 获取商户申请记录
 * @param int id
 *
 */
export function getApplicationRecordList(data) {
	return request.get('intention/lst', data);
}
/**
 * 获取商户申请详情
 * @param int id
 *
 */
export function getGoodsDetails(id) {
	return request.get('intention/detail/' + id, {});
}

/**
 * 修改入驻信息
 * @param int id
 *
 */
export function updateGoodsRecord(id, data) {
	return request.post('intention/update/' + id, data);
}
/**
 * 获取定位详细地址
 * @param int id
 *
 */
export function getGeocoder(data) {
	return request.get(`lbs/geocoder?location=${data.lat},${data.long}`, {}, {
		noAuth: true
	});
}
/**
 * 获取店铺类型
 * @param int id
 *
 */
export function getStoreTypeApi() {
	return request.get('intention/type', {}, {
		noAuth: true
	});
}
/**
 * 到货通知
 *
 */
export function arrivalNoticeApi(data) {
	return request.post('store/product/increase_take',data);
}

/*
  获取图片验证码
*/
export function getCaptcha() {
	return request.get('captcha');
}

/*
	获取店铺资质
*/
export function storeCertificate(data) {
	return request.post(`store/certificate/${data.merId}`, data)
}
/**
 * 本地服务列表
 * @returns {*}
 */
export function storeServiceList(id, data) {
	return request.get(`product/spu/local/${id}`, data, {
		noAuth: true
	});
}
/**
 * 复制口令
 * @returns {*}
 */
export function copyPasswordApi(data) {
	return request.get(`product/spu/copy`, data, {
		noAuth: true
	});
}
/**
 * 口令搜索
 * @returns {*}
 */
export function copyPasswordSearch(data) {
	return request.get(`command/copy`, data, {
		noAuth: true
	});
}
/**
 * 套餐列表
 * @returns {*}
 */
export function getDiscountsLst(data) {
	return request.get(`discounts/lst`, data, {
		noAuth: true
	});
}
/**
 * 套餐--立即购买
 * @returns {*}
 */
export function discountsCartAdd(data) {
	return request.post('user/cart/batchCreate', data);
}




/**
 * 商品列表
 */
export function productLstApi(merId, data) {
	return request.get(`shop/goods/getList`, data, { login: true });
}

/**
 * 商品列表 -- 删除
 */
export function productDeleteApi(merId, id) {
	return request.post(`server/${merId}/product/delete/${id}`, {}, { login: true });
}
/**
 * 商品列表 -- 删除
 */
export function productDeleteApiJoin(merId, id) {
	return request.post(`shop/goods/delete?ids=${id}`, {}, { login: true });
}

/**
 * 商品列表 -- 上下架
 */
export function productOffApi(merId, id) {
	return request.post(`shop/goods/putoff`, {ids:id}, { login: true });
}


export function productOffApiJoin(merId, id) {
	return request.post(`shop/goods/putoff?ids=${id}`, {}, { login: true });
}

export function productOnApi(merId, id) {
	return request.post(`shop/goods/puton`, {ids:id}, { login: true });
}

export function productOnApiJoin(merId, id) {
	return request.post(`shop/goods/puton?ids=${id}`, {}, { login: true });
}

/*
 售罄商品 -- 列表头部
*/

export function productTitle(merId, data) {
	return request.get(`server/${merId}/product/title`, data, { login: true });
}

/*
	回收站商品，彻底删除
*/

export function productDestory(merId, id, data) {
	return request.post(`server/${merId}/product/destory/${id}`, data, { login: true });
}

/*
	还原
*/

export function productRestore(merId, id) {
	return request.post(`server/${merId}/product/restore/${id}`, {}, { login: true });
}

/*
	添加或修改商品， 获取商品品牌
*/

export function categoryBrandlist(merId) {
	return request.get(`brand/list?pageSize=9999`, {}, { login: true });
}

/*
	添加修改商品, 获取商户分类
*/

export function categorySelect(merId) {
	return request.get(`common/shopCate/getList?shopId=${merId}`, {}, { login: true })
}

export function getMyShopCateList() {
	return request.get(`common/shopCate/getMyList`, {}, { login: true })
}



/**
 * 商品列表 -- 设置推荐
 */
export function productRecommendApi(merId, id, data) {
	return request.post(`server/${merId}/product/good/${id}`, data, { login: true });
}

/*
	获取规格列表
*/

export function attrList(merId, data) {
	return request.get(`server/${merId}/attr/lst`, data, { login: true })
}
/*
	请求运费模板
*/
export function templateList(merId, data) {
	return request.get(`server/${merId}/template/lst`, data, { login: true })
}
/*
	运费模板 -- 删除
*/
export function templateDelete(merId, data) {
	return request.post(`server/${merId}/template/delete`, data, { login: true })
}
/**
 * 运费模板 -- 详情
 */
export function templateDetail(merId, id) {
	return request.get(`server/${merId}/template/detail/${id}`, {}, { login: true });
}
/*
	运费模板 -- 添加
*/
export function templateCreate(merId, data) {
	return request.post(`server/${merId}/template/create`, data, { login: true });
}
/*
	运费模板 -- 编辑
*/
export function templateUpdate(merId, id, data) {
	return request.post(`server/${merId}/template/update/${id}`, data, { login: true });
}


/**
 * 商品规格项目 -- 列表
 */
export function specificationLst(merId, data) {
	return request.get(`server/${merId}/attr/lst`, data, { login: true });
}
/**
 * 商品规格项目 -- 删除
 */
export function specificationDel(merId, data) {
	return request.post(`server/${merId}/attr/delete`, data, { login: true });
}
/**
 * 商品规格项目 -- 添加
 */
export function specificationAdd(merId, data) {
	return request.post(`server/${merId}/attr/create`, data, { login: true });
}
/**
 * 商品规格项目 -- 编辑
 */
export function specificationUpdate(merId, id, data) {
	return request.post(`server/${merId}/attr/update/${id}`, data, { login: true });
}
/**
 * 商品规格项目 -- 详情
 */
export function specificationDetail(merId, id) {
	return request.get(`server/${merId}/attr/detail/${id}`, {}, { login: true });
}


/*
	添加商品 -- 获取送货方式信息
*/
export function getDeliveryType(merId) {
	return request.get(`server/${merId}/product/config`, {}, { login: true });
}

/*
	请求商品详情
*/
export function productDetail(merId, id) {
	return request.get(`shop/goods/get`, {goodsId:id}, {login: true});
}


/*
	商品管理， 添加商品
*/

export function productCreate(merId, data) {
	return request.post(`goods/add`, data, { login: true })
}
/*
	编辑商品
*/
export function productUpdate(merId, id, data) {
	data.id =  id
	return request.post(`goods/update`, data, { login: true });
}



/*
	添加修改商品， 获取平台分类
*/

export function categoryList(merId) {
	return request.get(`common/goodsCate/getList`, {}, { login: true })
}

/**
 * 店铺分类 -- 列表
 */
export function shopCateList() {
	return request.get(`common/shopCate/getList`, {}, { login: true });
}
/**
 * 店铺分类 -- 列表(删除)
 */
export function  shopCateDel(ids) {
	return request.post(`shop/cate/del`,{ids:ids}, { login: true });
}

/**
 * 上级分类 -- 商户列表
 */
export function shopCateLst(merId) {
	return request.get(`shop/cate/select`, {}, { login: true });
}
/**
 * 店铺分类 -- 添加/编辑
 */
export function shopCateSubmit(merId, data) {
	return request.post(`shop/cate/submit`, data, { login: true });
}

/**
 * 店铺分类 -- 详情
 */
export function shopCateDetail(merId, id) {
	return request.get(`shop/cate/detail`, {id:id}, { login: true });
}



